package d1016;

import java.time.LocalDateTime;
import java.util.Locale;
import java.util.Random;
import java.util.Scanner;

public class Text {
    public static class bookStore {
        static Book[] books = new Book[4];

        static {
            books[1] = new Book(1, "三国", 15, 5);
            books[2] = new Book(2, "西游", 15, 5);
            books[3] = new Book(3, "红楼", 15, 5);
            books[0] = new Book(4, "水浒", 15, 5);
        }

        public static void main(String[] args) {
            showBook(books);
            Person p=new Person("张三");
            Book book= p.buyBook(books);
            showTotal(book,p);

        }

        public static void showBook(Book[] book) {
            System.out.println("编号\t图书名称\t图书价格\t库存数量");
            for (int i = 0; i < book.length; i++) {
                System.out.println(book[i].getId() + "\t" + book[i].getName() + "\t" );
            }
        }
        public static void showTotal(Book book,Person p){
            Scanner sc=new Scanner(System.in);
            System.out.println("请输入购买数量");
            int num= sc.nextInt();
            double total= book.getPrice()*num;
            Random random=new Random();
            int orderNum=random.nextInt();
            System.out.println("订单编号"+Math.abs(orderNum));
            System.out.println("购物时间"+ LocalDateTime.now());
            System.out.println("会员"+p.getName());
            System.out.println("图书名称"+book.getName()+"\t单价"+book.getPrice()+"\t");
        }
    }
}
